ATSUGetTextHighlight

Obtains the highlight region for a range of text.

OSStatus ATSUGetTextHighlight (
                     ATSUTextLayout iTextLayout,
                     ATSUTextMeasurement iTextBasePointX,
                     ATSUTextMeasurement iTextBasePointY,
                     UniCharArrayOffset iHighlightStart,
                     UniCharCount iHighlightLength,
                     RgnHandle oHighlightRegion);
iTextLayout
A reference of type ATSUTextLayout. Pass a reference to an initialized text layout object. You cannot pass NULL for this parameter.

iTextBasePointX
A value of type ATSUTextMeasurement. Pass the x-coordinate of the origin of the line (in the current graphics port) containing the range of text whose highlight region you want to obtain. Pass the constant kATSUUseGrafPortPenLoc, described in Current Pen Location Constant, if you want to obtain the highlighting region relative to the current pen location in the current graphics port.

iTextBasePointY
A value of type ATSUTextMeasurement. Pass the y-coordinate of the origin of the line (in the current graphics port) containing the range of text whose highlight region you want to obtain. Pass the constant kATSUUseGrafPortPenLoc, described in Current Pen Location Constant, if you want to obtain the highlighting region relative to the current pen location in the current graphics port.

iHighlightStart
A value of type UniCharArrayOffset. Pass the edge offset that corresponds to the beginning of the range of text whose highlight region you want to determine. To indicate the beginning of the text buffer, pass the constant kATSUFromTextBeginning, described in Text Offset Constant. To indicate the entire text buffer, pass kATSUFromTextBeginning in this parameter and the constant kATSUToTextEnd in the iHighlightLength parameter. If the offset is outside the text buffer, ATSUGetTextHighlight returns the result code kATSUInvalidTextRangeErr.

iHighlightLength
A value of type UniCharCount. Pass the length of the range of text whose highlight region you want to determine. To indicate the end of the text buffer, pass the constant kATSUToTextEnd, described in Text Length Constant. To indicate the entire text buffer, pass kATSUToTextEnd in this parameter and the constant kATSUFromTextBeginning in the iHighlightStart parameter. If the range of text is outside the text buffer, ATSUGetTextHighlight returns the result code kATSUInvalidTextRangeErr.

oHighlightRegion
A handle of type RgnHandle. Before calling ATSUGetTextHighlight, create a region handle by calling the NewRgn function. On return, RgnHandle points to a RgnPtr which points to a Region structure. The structure has two fields, rgnSize and rgnBBox, that represent the highlight region for the text. In the case of discontiguous highlighting, the region consists of multiple components, with the rgnBBox field specifying the bounding box around the entire area of discontiguous highlighting. You cannot pass NULL for this parameter.

function result
A result code. The result code kATSUCoordinateOverflowErr indicate that the coordinates passed in the iTextBasePointX and iTextBasePointY parameters caused a coordinate overflow. The result code kATSUInvalidCacheErr indicates that an attempt was made to read in style data from an invalid cache. This may be because the format of the cached data does not match that used by ATSUI or the cached data is corrupt. The result code kATSUQuickDrawTextErr indicates that the QuickDraw function DrawText encountered an error while measuring a line of text. For a list of other ATSUI-specific result codes, see Result Codes.
DISCUSSION
The ATSUGetTextHighlight function determines the highlight region for a range of text. It does not highlight the text.

When there are discontiguous highlighting regions, the structure passed back in the oHighlightRegion parameter is made up of multiple components. The rgnBBox field of the structure represents the bounding box around the entire area of discontiguous highlighting. In ATSUI 1.1, the maximum number of components that can be passed back is 31; in version 1.2, the maximum is 127.

ATSUGetTextHighlight uses the previously set line ascent and descent values to calculate the height of the highlight region. If these values have not been set for the line, ATSUGetTextHighlight uses the line ascent and descent values set for the text layout object containing the line. If these are not set, it uses the default values.

SPECIAL CONSIDERATIONS
ATSUGetTextHighlight may allocate memory in your application heap, unless you designate a different heap by calling the function ATSUCreateMemorySetting.

VERSION NOTES
Available beginning with ATSUI 1.0. In ATSUI 1.2, the maximum number of components that can be passed back is 127.


© 2000 Apple Computer, Inc. – (Last Updated 25 Jan 00)